#pragma once
#include <osg/NodeVisitor>
#include <osg/Program>

/** 
 * \class CApplyShaderToTexturedGeodeVisitor
 * \brief visitor that applies a shader to all textured drawable
 **/
class CApplyShaderToTexturedGeodeVisitor : public osg::NodeVisitor
{
public:
	/// constructor
	/// \param shader shader that will be applied to all textured drawable
	/// \param traversalMode traversal mode
	CApplyShaderToTexturedGeodeVisitor(osg::Program* shaderProgram, osg::NodeVisitor traversalMode = TRAVERSE_ALL_CHILDREN);

	/// set concerned texture unit
	/// \param unit texture unit to find  
	void setTextureUnit(int unit);

	void addShaderUniform(osg::Uniform*);

	/// virtual visitor method
	/// \param node currend visited node
	virtual void apply(osg::Node& node);

private:
	/// textured drawable shader
	osg::ref_ptr<osg::Program> m_shader;
	// shader uniform list
	std::vector<osg::Uniform*> m_uniformList;
};

inline void CApplyShaderToTexturedGeodeVisitor::addShaderUniform(osg::Uniform* u)
{
	m_uniformList.push_back(u);
}